package com.xr.common.exception;

import com.xr.common.axios.AxiosEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class MyCustomException extends RuntimeException {

    private final Integer code;

    public MyCustomException() {
        super(AxiosEnum.UNKNOWN_ERROR.getMsg());
        this.code = AxiosEnum.UNKNOWN_ERROR.getCode();
    }

    public MyCustomException(String message) {
        super(message);
        this.code = AxiosEnum.UNKNOWN_ERROR.getCode();
    }

    public MyCustomException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    public MyCustomException(AxiosEnum axiosEnum) {
        super(axiosEnum.getMsg());
        this.code = axiosEnum.getCode();
    }

    @Override
    public String toString() {
        return "MyCustomException{" + "code = " + code + ", message = " + this.getMessage() + '}';
    }

}
